<template>
<div>
    <form>
    姓名:<input type="text" v-model="name">
    <br> <br>
    年龄:<input type="text" v-model.number="age">
    <br> <br>
    身高:<input type="text" v-model="long">米
    <br> <br>
    体重:<input type="text" v-model.number="weight">公斤
    <br> <br>
    病例:<input type="text" v-model="bl">
    <br> <br>
    <input type="submit" name="" id="" value="诊断" @click.prevent="zd">
 </form>
 <p ref="refd"></p>
</div>

 
</template>

<script>
export default {
 data () {
 return {
    name:'',
    age:'',
    long:'',
    weight:'',
    bl:'',
    BMI:'',
    txt:''
   }
 },
 components: {},
 methods: {
    zd(){
        this.BMI=this.weight/(this.long*this.long)
        if(this.BMI<=18.5){
            this.txt='体重过轻'
        }else if(this.BMI>18.5&&this.BMI<=24.9){
            this.txt='正常'
        }
        else if(this.BMI>24.9&&this.BMI<=29.9){
            this.txt='体重过重'
        }else{
            this.txt='肥胖'
        }
        this.$refs.refd.innerHTML='患者 '+this.name+' 的诊断结果 '+this.txt
    }
 }
}
</script>

<style scoped>
</style>